package com.kingcore.director.main;

import java.awt.Color;
import java.io.Serializable;

import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumnModel;

public class MainFrameBean extends JPanel implements Serializable{
 
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	DefaultTableModel dtm;
	private JScrollPane jScrollPane = null;
	private JTable jTable = null;
	private MainFrame mf = null;
 
	/**
	 * This method initializes jScrollPane	
	 * 	
	 * @return javax.swing.JScrollPane	
	 */
	private JScrollPane getJScrollPane() {
		if (jScrollPane == null) {
			jScrollPane = new JScrollPane();
			jScrollPane.setBounds(new java.awt.Rectangle(172,12,234,235));
			jScrollPane.setViewportView(getJTable());
		}
		return jScrollPane;
	}

	/**
	 * This method initializes jTable	
	 * 	
	 * @return javax.swing.JTable	
	 */
	private JTable getJTable() {
		if (jTable == null) {
			jTable = new JTable();
		}
		return jTable;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

	/**
	 * This is the default constructor
	 */
	public MainFrameBean() {
		super();
		initialize();
	}
	private void jTableInit(){


	    //System.out.println("-----1");
	    Object[][] data = {
	       {
	        "Jackson", new Integer(4), "March 21"
	      }, {
	        "Zachary", new Integer(2), "May 12"
	      }
	    };
	    String[] headers = {
	      "名称", "提醒时间", "主要内容"
	    };

	    // A DefaultTableModel object is created and initialized with some
	    // data and headers.

	    dtm = new DefaultTableModel(2, 3);
	    dtm.setDataVector(data, headers);

		//((DefaultTableModel)jTable.getModel()).setColumnIdentifiers( new String[]{"启用否","文件路径","aa"});
		
	    this.jTable.setModel(dtm);
	    this.jTable.setGridColor(Color.BLUE);
	    this.jTable.setRowSelectionAllowed(true);
	    this.jTable.setRowSelectionInterval(1, 1);

	    // 更改列宽度
	    TableColumnModel cm = jTable.getColumnModel();
	    cm.getColumn(0).setResizable(true);
	    cm.getColumn(0).setWidth(150);
	    cm.getColumn(1).setWidth(80);
	    cm.getColumn(2).setWidth(300);
	    
	}
	/**
	 * This is the default constructor
	 */
	public MainFrameBean(MainFrame mf) {
		super();
		this.mf= mf;
		initialize();
	}
	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setLayout(null);
		//this.setSize(412, 259);
		//this.add(getJTree(), null);
		this.add(getJScrollPane(), null);
		
		this.setSize(this.mf.getSize().width-8,this.mf.getSize().height-106);

		//this.getJTree().setBounds(5,5,150, this.getSize().height-10);
		this.getJScrollPane().setBounds(160, 5, this.getSize().width - 160-10,
				this.getSize().height-10);
		
		//this.getJTree().setSize(150, this.getSize().height-8);
		//this.getJScrollPane().setSize(this.getSize().width - 160,
		//		this.getSize().height-8);
		doResize();
		
		jTableInit();
	}
	/**
	 * add by wzw
	 *
	 */
	void doResize(){

		//wzw
		//System.out.println("------1==="+this.mf.getSize());
		//this.setSize(this.mf.getSize().width,this.mf.getSize().height-111);
		//System.out.println(this.getSize().height);
		//因为位于容器的center,所以自动会调整大小，只用改里面组件的位置和大小。

		//this.getJTree().setSize(150, this.getSize().height-8);
		this.getJScrollPane().setSize(this.getSize().width - 160,
				this.getSize().height-8);

		//this.getJTree().setBounds(5,5,150, this.getSize().height-20);
		//this.getJScrollPane().setBounds(160, 5, this.getSize().width - 160-10,
		//		this.getSize().height-20);
		
	}

	public DefaultTableModel getDtm() {
		return dtm;
	}

	public void setDtm(DefaultTableModel dtm) {
		this.dtm = dtm;
	}

}  //  @jve:decl-index=0:visual-constraint="10,10"
